import { ToggleCollapsed, AddTags } from './_action';

const stateData = {
  tagsMap: [],
  tagsTitle: []
};
export function toggleCollapsed(state = { collapsed: false }, action) {
  switch (action.type) {
    case 'toggle':
      return { collapsed: !state.collapsed };
    default:
      return state;
  }
}
// 添加头部标签，待开发
export function addTags(state = stateData, action) {
  switch (action.type) {
    case 'ADD_TAGS':
      if (state.tagsMap.indexOf(action.text) == -1) {
        state.tagsMap.push(action.text);
        state.tagsTitle.push(action.title);
      }
      return { tagsMap: state.tagsMap, tagsTitle: state.tagsTitle };
    case 'REMOVE_TAGS':
      const num = state.tagsMap.indexOf(action.text);
      state.tagsMap.splice(num, 1);
      state.tagsTitle.splice(num, 1);
      return { tagsMap: state.tagsMap, tagsTitle: state.tagsTitle };
    default:
      return state;
  }
}

// export default setCounter;

